package limeirafol.gui.venda;

import javax.swing.SwingConstants;
import lbframework.bean.consultaCampo.LBConsultaCampo;
import lbframework.bean.internalFrame.LBInternalFrame;
import lbframework.bean.mdiFrame.LBMdiFrame;
import lbframework.bean.table.LBColumnTable;
import lbframework.classe.Util;
import limeirafol.bean.BeanVenda;
import limeirafol.gui.Cadastro.ClienteConsultaGUI;
import limeirafol.gui.MenuGUI;
import limeirafol.remote.venda.OrdemServicoItemVO;
import limeirafol.remote.venda.OrdemServicoVO;
import limeirafol.remote.venda.SituacaoOrdemServico;
import limeirafol.remote.venda.SituacaoPedido;
import limeirafol.remote.venda.TipoOrdemServico;

public class OrdemServicoCadastroGUI extends LBInternalFrame {

    public OrdemServicoVO oOrdemServico = new OrdemServicoVO();
    private BeanVenda beanVenda = new BeanVenda();

    public OrdemServicoCadastroGUI(LBMdiFrame i_mdiFrame) throws Exception {
        super(i_mdiFrame);

        initComponents();
        centralizarForm();

        txtDataHoraAbertura.setText(Util.getDataHoraAtual());

        cnsCliente.setTabela("cliente");
        cnsCliente.setCampoDescricao("nome");

        cboSituacao.setTabela("situacaoordemservico");
        cboSituacao.carregar();
        cboSituacao.setId(SituacaoOrdemServico.ABERTA.getId());

        habilitaTela();

    }

    public void exibirProduto() throws Exception {
        LBColumnTable[] colunas = new LBColumnTable[]{
            new LBColumnTable("Produto", 70, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Descrição", 240, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Quantidade", 75, true, SwingConstants.LEFT, false, null),};

        Object[][] dados = new Object[oOrdemServico.vItem.size()][colunas.length];

        int i = 0;

        for (OrdemServicoItemVO oItem : oOrdemServico.vItem) {
            dados[i][0] = Util.formatNumber(oItem.idProduto, 6);

            i++;

        }

        tblItens.setModel(dados, colunas);

    }

    @Override
    public void incluir() throws Exception {
        verificarAlteracaoTela();

        txtNumeroPedido.setText("");
        cnsCliente.clear();
        txtDataHoraAbertura.setText(Util.getDataHoraAtual());
        cboSituacao.setId(SituacaoPedido.EM_DIGITACAO.getId());
        txtDataHoraFinalizacao.setText("");
        tblItens.clear();

        cnsCliente.requestFocus();

        oOrdemServico = new OrdemServicoVO();

        habilitaTela();

        getEstadoTelaInicial();
    }

    @Override
    public void salvar() throws Exception {
        Util.validarCampoTela(this.getCampoObrigatorio());

        oOrdemServico.dataHoraAbertura = Util.formatDataHoraBanco(txtDataHoraAbertura.getText());
        oOrdemServico.dataHoraFinalizacao = txtDataHoraFinalizacao.getText();
        oOrdemServico.idCliente = cnsCliente.getId();
        oOrdemServico.idSituacao = cboSituacao.getId();

        //beanPedido.salvarPedido(oOrdemServico);

        Util.exibirMensagem(Util.MSG_SALVO_SUCESSO, getTitle());

        txtNumeroPedido.setText(Util.formatNumber(oOrdemServico.id, 6));

        getEstadoTelaInicial();

        habilitaTela();

    }

    @Override
    public void finalizar() throws Exception {
    }

    @Override
    public void estornar() throws Exception {
    }

    @Override
    public void cancelar() throws Exception {
    }

    private void habilitaTela() throws Exception {
        if (cboSituacao.getId() == SituacaoOrdemServico.ABERTA.getId()) {
            if (cboTipoOrdemServico.getId() == TipoOrdemServico.PEDIDO.getId()) {
                btnAdicionar.setEnabled(false);
                btnRemover.setEnabled(false);
                btnLimpar.setEnabled(false);

            } else {
                btnAdicionar.setEnabled(true);
                btnRemover.setEnabled(true);
                btnLimpar.setEnabled(true);
            }

            lBToolBarPadrao1.setEnabledEstornar(false);
            lBToolBarPadrao1.setEnabledSalvar(false);

        } else if (cboSituacao.getId() == SituacaoOrdemServico.FINALIZADA.getId()) {
        }
    }

    public void carregarPedido(long i_numeroPedido) throws Exception {
        //oOrdemServico = beanPedido.carregarPedido(i_numeroPedido);

        txtNumeroPedido.setText(Util.formatNumber(i_numeroPedido, 6));
        cnsCliente.setId(oOrdemServico.idCliente);
        cnsCliente.consultar();
        txtDataHoraAbertura.setText(oOrdemServico.dataHoraAbertura);
        cboSituacao.setId(oOrdemServico.idSituacao);
        txtDataHoraFinalizacao.setText(oOrdemServico.dataHoraFinalizacao);

        habilitaTela();

        exibirProduto();

        getEstadoTelaInicial();
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        popImpressao = new javax.swing.JPopupMenu();
        btnImprimirPedido = new javax.swing.JMenuItem();
        btnImprimirInvoice = new javax.swing.JMenuItem();
        lBPanel1 = new lbframework.bean.panel.LBPanel();
        lBLabel1 = new lbframework.bean.label.LBLabel();
        txtNumeroPedido = new lbframework.bean.textField.LBTextField();
        lBLabel2 = new lbframework.bean.label.LBLabel();
        cnsCliente = new lbframework.bean.consultaCampo.LBConsultaCampo();
        lBLabel3 = new lbframework.bean.label.LBLabel();
        cboSituacao = new lbframework.bean.comboBox.LBComboBox();
        lBLabel4 = new lbframework.bean.label.LBLabel();
        txtDataHoraAbertura = new lbframework.bean.textField.LBTextField();
        txtDataHoraFinalizacao = new lbframework.bean.textField.LBTextField();
        lBLabel9 = new lbframework.bean.label.LBLabel();
        cboTipoOrdemServico = new lbframework.bean.comboBox.LBComboBox();
        lBLabel5 = new lbframework.bean.label.LBLabel();
        lBPanel2 = new lbframework.bean.panel.LBPanel();
        tblItens = new lbframework.bean.tableEx.LBTableEx();
        btnAdicionar = new lbframework.bean.button.LBButton();
        btnRemover = new lbframework.bean.button.LBButton();
        btnLimpar = new lbframework.bean.button.LBButton();
        lBPanel4 = new lbframework.bean.panel.LBPanel();
        btnSair = new lbframework.bean.button.LBButton();
        btnSalvar = new lbframework.bean.button.LBButton();
        lBToolBar1 = new lbframework.bean.toolBar.LBToolBar();
        lBToolBarPadrao1 = new lbframework.bean.toolBarPadrao.LBToolBarPadrao(this);

        btnImprimirPedido.setText("Pedido");
        btnImprimirPedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImprimirPedidoActionPerformed(evt);
            }
        });
        popImpressao.add(btnImprimirPedido);

        btnImprimirInvoice.setText("Invoice");
        btnImprimirInvoice.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImprimirInvoiceActionPerformed(evt);
            }
        });
        popImpressao.add(btnImprimirInvoice);

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Ordem de Serviço");
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosing(evt);
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        lBLabel1.setText("Numero O.S.");

        txtNumeroPedido.setColumns(6);
        txtNumeroPedido.setEnabled(false);
        txtNumeroPedido.setMascara("Numero");

        lBLabel2.setText("Cliente");

        cnsCliente.setColumns(6);
        cnsCliente.setEnabled(false);
        cnsCliente.setObrigatorio(true);
        cnsCliente.addEventoConsultaCampoListener(new lbframework.bean.consultaCampo.LBEventoConsultaCampoListener() {
            public void abreTelaConsulta(lbframework.bean.consultaCampo.LBEventoConsultaCampo evt) {
                cnsClienteAbreTelaConsulta(evt);
            }
            public void aposConsulta(lbframework.bean.consultaCampo.LBEventoConsultaCampo evt) {
            }
        });

        lBLabel3.setText("Situacao");

        cboSituacao.setEnabled(false);

        lBLabel4.setText("Data/Hora Abertura");

        txtDataHoraAbertura.setEnabled(false);

        txtDataHoraFinalizacao.setEnabled(false);

        lBLabel9.setText("Data/Hora Finalização");

        cboTipoOrdemServico.setEnabled(false);

        lBLabel5.setText("Tipo Ordem Serviço");

        javax.swing.GroupLayout lBPanel1Layout = new javax.swing.GroupLayout(lBPanel1);
        lBPanel1.setLayout(lBPanel1Layout);
        lBPanel1Layout.setHorizontalGroup(
            lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lBPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(lBPanel1Layout.createSequentialGroup()
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNumeroPedido, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lBLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lBLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cnsCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 367, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lBLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDataHoraAbertura, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(lBPanel1Layout.createSequentialGroup()
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtDataHoraFinalizacao, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lBLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lBLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(341, 341, 341)
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lBLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cboTipoOrdemServico, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        lBPanel1Layout.setVerticalGroup(
            lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lBPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(lBPanel1Layout.createSequentialGroup()
                        .addComponent(lBLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboTipoOrdemServico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(lBPanel1Layout.createSequentialGroup()
                            .addComponent(lBLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtDataHoraAbertura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(lBPanel1Layout.createSequentialGroup()
                                .addComponent(lBLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cnsCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(lBPanel1Layout.createSequentialGroup()
                                .addComponent(lBLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtNumeroPedido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(lBPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(lBPanel1Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(txtDataHoraFinalizacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lBLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(lBPanel1Layout.createSequentialGroup()
                        .addComponent(lBLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        lBPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Itens Ordem de Serviço"));

        tblItens.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblItensMouseClicked(evt);
            }
        });
        tblItens.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tblItensKeyPressed(evt);
            }
        });

        btnAdicionar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/adicionar.png"))); // NOI18N
        btnAdicionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAdicionarActionPerformed(evt);
            }
        });

        btnRemover.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/remover.png"))); // NOI18N

        btnLimpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/limpar.png"))); // NOI18N

        javax.swing.GroupLayout lBPanel2Layout = new javax.swing.GroupLayout(lBPanel2);
        lBPanel2.setLayout(lBPanel2Layout);
        lBPanel2Layout.setHorizontalGroup(
            lBPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lBPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(lBPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, lBPanel2Layout.createSequentialGroup()
                        .addComponent(btnAdicionar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRemover, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnLimpar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(tblItens, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        lBPanel2Layout.setVerticalGroup(
            lBPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, lBPanel2Layout.createSequentialGroup()
                .addComponent(tblItens, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(lBPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnRemover, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAdicionar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnLimpar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        btnSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/sair.png"))); // NOI18N
        btnSair.setText("Sair");
        btnSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSairActionPerformed(evt);
            }
        });

        btnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/salvar.png"))); // NOI18N
        btnSalvar.setText("Salvar");
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout lBPanel4Layout = new javax.swing.GroupLayout(lBPanel4);
        lBPanel4.setLayout(lBPanel4Layout);
        lBPanel4Layout.setHorizontalGroup(
            lBPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, lBPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnSair, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        lBPanel4Layout.setVerticalGroup(
            lBPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lBPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(btnSair, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(btnSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        lBToolBar1.setRollover(true);

        lBToolBarPadrao1.setRollover(true);
        lBToolBarPadrao1.setVisibleCancelar(true);
        lBToolBarPadrao1.setVisibleEstornar(true);
        lBToolBarPadrao1.setVisibleFinalizar(true);
        lBToolBarPadrao1.setVisibleIncluir(true);
        lBToolBarPadrao1.setVisibleSalvar(true);
        lBToolBar1.add(lBToolBarPadrao1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lBPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lBToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lBPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lBPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(lBToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lBPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lBPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lBPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairActionPerformed
        try {
            verificarAlteracaoTela();
            sair();

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_btnSairActionPerformed

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
        try {
            salvar();

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_btnSalvarActionPerformed

    private void cnsClienteAbreTelaConsulta(lbframework.bean.consultaCampo.LBEventoConsultaCampo evt) {//GEN-FIRST:event_cnsClienteAbreTelaConsulta
        try {
            MenuGUI menu = (MenuGUI) mdiFrame;

            if (menu.formClienteConsulta == null || menu.formClienteConsulta.isClosed()) {
                menu.formClienteConsulta = new ClienteConsultaGUI(mdiFrame);
            }

            menu.formClienteConsulta.setConsultaCampo(cnsCliente);
            menu.formClienteConsulta.setVisible(true);

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_cnsClienteAbreTelaConsulta

    private void tblItensKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblItensKeyPressed
    }//GEN-LAST:event_tblItensKeyPressed

    private void tblItensMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblItensMouseClicked
    }//GEN-LAST:event_tblItensMouseClicked

    private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing
        try {
            verificarAlteracaoTela();
            sair();

        } catch (Exception e) {
            Util.exibirMensagemErro(e, getTitle());
        }
    }//GEN-LAST:event_formInternalFrameClosing

    private void btnImprimirPedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirPedidoActionPerformed
}//GEN-LAST:event_btnImprimirPedidoActionPerformed

    private void btnImprimirInvoiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirInvoiceActionPerformed
}//GEN-LAST:event_btnImprimirInvoiceActionPerformed

    private void btnAdicionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdicionarActionPerformed
        try {
            // adicionarProduto();
        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
}//GEN-LAST:event_btnAdicionarActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private lbframework.bean.button.LBButton btnAdicionar;
    private javax.swing.JMenuItem btnImprimirInvoice;
    private javax.swing.JMenuItem btnImprimirPedido;
    private lbframework.bean.button.LBButton btnLimpar;
    private lbframework.bean.button.LBButton btnRemover;
    private lbframework.bean.button.LBButton btnSair;
    private lbframework.bean.button.LBButton btnSalvar;
    private lbframework.bean.comboBox.LBComboBox cboSituacao;
    private lbframework.bean.comboBox.LBComboBox cboTipoOrdemServico;
    private lbframework.bean.consultaCampo.LBConsultaCampo cnsCliente;
    private lbframework.bean.label.LBLabel lBLabel1;
    private lbframework.bean.label.LBLabel lBLabel2;
    private lbframework.bean.label.LBLabel lBLabel3;
    private lbframework.bean.label.LBLabel lBLabel4;
    private lbframework.bean.label.LBLabel lBLabel5;
    private lbframework.bean.label.LBLabel lBLabel9;
    private lbframework.bean.panel.LBPanel lBPanel1;
    private lbframework.bean.panel.LBPanel lBPanel2;
    private lbframework.bean.panel.LBPanel lBPanel4;
    private lbframework.bean.toolBar.LBToolBar lBToolBar1;
    private lbframework.bean.toolBarPadrao.LBToolBarPadrao lBToolBarPadrao1;
    private javax.swing.JPopupMenu popImpressao;
    private lbframework.bean.tableEx.LBTableEx tblItens;
    private lbframework.bean.textField.LBTextField txtDataHoraAbertura;
    private lbframework.bean.textField.LBTextField txtDataHoraFinalizacao;
    private lbframework.bean.textField.LBTextField txtNumeroPedido;
    // End of variables declaration//GEN-END:variables
}
